package com.ougy.reshop.service.impl;

import java.sql.Timestamp;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.annotation.Resource;

import org.hibernate.criterion.DetachedCriteria;

import com.ougy.reshop.dao.IAccessoryDao;
import com.ougy.reshop.dao.IAlbumDao;
import com.ougy.reshop.dao.IGoodsClassDao;
import com.ougy.reshop.dao.IPublishDao;
import com.ougy.reshop.dao.IRegionDao;
import com.ougy.reshop.dao.IUserDao;
import com.ougy.reshop.service.IBaseServices;
import com.ougy.reshop.util.PaginationSupport;

public class BaseServices implements IBaseServices {

	protected Map session;

	public Map getSession() {
		return session;
	}

	public String getUuid() {
		return UUID.randomUUID().toString().replaceAll("-", "");
	}

	public void setSession(Map session) {
		this.session = session;
	}

	public Timestamp getTimestamp() {
		return new Timestamp(System.currentTimeMillis());
	}
	public List findAllByCriteria(DetachedCriteria detachedCriteria) {
		return userDao.findAllByCriteria(detachedCriteria);
	}

	public PaginationSupport findPageByCriteria(
			DetachedCriteria detachedCriteria) {
		return userDao.findPageByCriteria(detachedCriteria);
	}

	public PaginationSupport findPageByCriteria(
			DetachedCriteria detachedCriteria, int page) {
		return userDao.findPageByCriteria(detachedCriteria, page);
	}

	public PaginationSupport findPageByCriteria(
			DetachedCriteria detachedCriteria, int pageSize, int page) {
		return userDao.findPageByCriteria(detachedCriteria, pageSize, page);
	}

	public PaginationSupport findPageByIndex(DetachedCriteria detachedCriteria,
			int pageSize, int startIndex) {
		return userDao.findPageByIndex(detachedCriteria, pageSize, startIndex);
	}

	public int getCountByCriteria(DetachedCriteria detachedCriteria) {
		return userDao.getCountByCriteria(detachedCriteria);
	}

	
	protected IUserDao userDao;
	protected IPublishDao publishDao;
	protected IGoodsClassDao goodsClassDao;
	protected IAlbumDao albumDao;
	protected IAccessoryDao accessoryDao;
	protected IRegionDao regionDao;
	
	public IRegionDao getRegionDao() {
		return regionDao;
	}
	@Resource
	public void setRegionDao(IRegionDao regionDao) {
		this.regionDao = regionDao;
	}

	public IAccessoryDao getAccessoryDao() {
		return accessoryDao;
	}
	@Resource
	public void setAccessoryDao(IAccessoryDao accessoryDao) {
		this.accessoryDao = accessoryDao;
	}

	public IAlbumDao getAlbumDao() {
		return albumDao;
	}
	@Resource
	public void setAlbumDao(IAlbumDao albumDao) {
		this.albumDao = albumDao;
	}

	public IGoodsClassDao getGoodsClassDao() {
		return goodsClassDao;
	}

	@Resource
	public void setGoodsClassDao(IGoodsClassDao goodsClassDao) {
		this.goodsClassDao = goodsClassDao;
	}

	public IUserDao getUserDao() {
		return userDao;
	}

	@Resource
	public void setUserDao(IUserDao userDao) {
		this.userDao = userDao;
	}

	public IPublishDao getPublishDao() {
		return publishDao;
	}

	@Resource
	public void setPublishDao(IPublishDao publishDao) {
		this.publishDao = publishDao;
	}

}
